package com.tvunetworks.center.user.util;

import com.tvunetworks.center.common.util.SnowflakeDistributeId;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @program: tvucc-user
 * @description:
 * @author lebronchen
 * @create: 2019-03-20 10:29
 **/
@Component
@Primary
public class DistributedGlobalIdUtil {

//	private static SnowflakeDistributeId snowflakeDistributeId = null;
	private static SnowflakeDistributeId SNOWFLAKEDISTRIBUTEID = null;

	/**
	 * init
	 */
	@PostConstruct
	public void init(){
		inits();
	}
	/**
	 * 静态调用赋值,符合封装原则
	 */
	public  static void inits(){

		SNOWFLAKEDISTRIBUTEID = new SnowflakeDistributeId(0,4);
	}
	/**
	 *
	 * @return  long
	 */
	public long netxId(){
	    return SNOWFLAKEDISTRIBUTEID.nextId();
	}
}
